<template>
  <a-card hoverable @click="router.push(`/exam/preview/${item.id}`)">
    <a-flex>
      <div>
        <a-image :width="145" :height="120" :src="getFile(item.image)" :preview="false" />
      </div>
      <div class="item-content">
        <router-link :to="`/exam/preview/${item.id}`">
          <a-tag v-if="item.passed === 1" color="#87d068">已通过</a-tag>
          <a-tag v-else-if="item.passed === 0" color="#f50">未通过</a-tag>
          <span class="title">{{ item.title }}</span>
        </router-link>
        <p>
          时长：{{ item.totalTime }}分钟 <br />
          开始：{{ item.startTime }} <br />
          截止：{{ item.endTime }} <br />
        </p>
        <p class="tagClass">
          <a-tag v-if="item.state === 0" color="#87d068">进行中</a-tag>
          <a-tag v-else-if="item.state === 2" color="#f50">未开始</a-tag>
          <a-tag v-else-if="item.state === 3" color="#f50">已结束</a-tag>
        </p>
      </div>
    </a-flex>
  </a-card>
</template>
<script lang="ts" setup>
import router from "@/router";

const props = defineProps({
  loading: {
    type: Boolean,
    default: false
  },
  item: {
    type: Object,
    default: {}
  }
});

</script>
<style lang="less" scoped>
.tagClass {
  font-size: 14px;
}

.item-content {
  margin-left: 20px;
  width: 100%;
  text-align: left;

  .title {
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    line-height: 16px;
  }

  p {
    margin: 8px 0;
    font-size: 13px;
    color: #777;
    letter-spacing: 0;
    line-height: 22px;

    a {
      color: #3370ff;
      display: inline;
    }
  }

  span {
    line-height: 14px;
  }

  a {
    transition: color .3s;
    overflow: hidden;
    display: flex;
    cursor: pointer;
    color: black;
  }

  a:hover {
    color: #3370ff;
  }
}
</style>
